﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Maticsoft.DBUtility;

namespace Taxes.DAL
{
    public class Report1
    {
        public List<Model.Report1> GetReports(string ny, int type)
        {
            var sqlParm = new SqlParameter[] { 
                new SqlParameter(){ ParameterName="@lr_ny" , Value= ny,DbType=System.Data.DbType.String},
                new SqlParameter(){ParameterName="@lr_type" ,Value=type,DbType= System.Data.DbType.Int32}
            };
             var  ds = DbHelperSQL.RunProcedure("up_getTaxOrderby", sqlParm, "report1");
            var dt = ds.Tables["report1"];
            var list = new List<Model.Report1>();
            foreach (DataRow row in dt.Rows)
            {
                var r = new Model.Report1();
                if (row["ID"] != null && row["ID"].ToString() != "")
                {
                    r.ID = int.Parse(row["ID"].ToString());
                }
                switch (type)
                
                {
                    case 0:
                        r.Name = row["region_name"].ToString();
                        break;
                    case 1:
                        r.Name = row["industry_name"].ToString();
                        break;
                }
                r.Tax_Sum = decimal.Parse(row["tax_sum"].ToString());
                r.Tax = decimal.Parse(row["tax"].ToString());
                list.Add(r);
                
            }
            return list;

        }
    }
}
